package com.xncoding.netty.handler.http;

import com.alibaba.fastjson.JSON;

import com.xncoding.netty.model.http.HttpResponseMsg;
import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.SimpleChannelInboundHandler;

public class JsonHttpServerHandler extends ChannelInboundHandlerAdapter{
	String charset = "UTF-8";
	 @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {

	 System.out.println("内容j:" + JSON.toJSONString(msg));
//        ctx.writeAndFlush(JSON.toJSONString(msg));
        
        HttpResponseMsg hrm = new HttpResponseMsg();
    	hrm.setResType(HttpResponseMsg.ResType.JSON.getValue());
    	hrm.setResCode(HttpResponseMsg.ResCode.OK.getValue());
    	hrm.setMessage(msg.toString());
    	ctx.writeAndFlush(hrm);
    }

}

